package com.dongliu.service.impl;

import com.dongliu.dao.UserDao;
import com.dongliu.domain.User;
import com.dongliu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    public boolean save(User user) {
        return userDao.save(user) > 0;
    }

    public boolean update(User user) {
        return userDao.update(user) > 0;
    }

    public boolean updateById(User user){
        return userDao.updateById(user) > 0;
    }

    public boolean delete(String username) {
        return userDao.delete(username) > 0;
    }

    public User getByUsername(String username) {
        return userDao.getByUsername(username);
    }

    public User getById(Integer id) {
        return userDao.getById(id);
    }

    public List<User> getAll() {
        return userDao.getAll();
    }

    public int getCount(){
        return userDao.getCount();
    }

    public User login(String username, String password){
        return userDao.login(username, password);
    }
}
